package com.dzg.demo.example.singleton;

import com.dzg.demo.annoations.NotThreadSafe;

/*
 *  懒汉模式
 * @author dzg  
 * @date 2018/8/30 21:22
 * @param    
 * @return   
 */
@NotThreadSafe
public class SingletonExample1 {
//  私有构造函数
    private SingletonExample1() {
    }
//  单例对象
    private static SingletonExample1 instance = null;
//  静态的工厂方法
    public static SingletonExample1 getInstance(){
        if(instance == null){
            instance = new SingletonExample1();
        }
        return instance;
    }
}
